<!DOCTYPE html>
<html>
<head>
    <title></title>
    #parse("sys/header.html")
    <style>
        .upload-list {
            display: inline-block;
            width: 60px;
            height: 60px;
            text-align: center;
            line-height: 60px;
            border: 1px solid transparent;
            border-radius: 4px;
            overflow: hidden;
            background: #fff;
            position: relative;
            box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
            margin-right: 4px;
        }

        .upload-list img {
            width: 100%;
            height: 100%;
        }

        .upload-list-cover {
            display: none;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(0, 0, 0, .6);
        }

        .upload-list:hover .upload-list-cover {
            display: block;
        }

        .upload-list-cover i {
            color: #fff;
            font-size: 20px;
            cursor: pointer;
            margin: 0 2px;
        }
    </style>
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <Row :gutter="16">
            <div class="search-group">
                <i-col span="2">
                    <i-select v-model="q.goodsType">
                    	<i-option v-for="item in goodsTypeList" :label="item.key">{{ item.value }}</i-option>
                    </i-select>
                </i-col>
                <i-col span="4">
                    <i-input v-model="q.name" @on-enter="query" placeholder="名称"/>
                </i-col>
                <i-button @click="query">查询</i-button>
            </div>
            <div class="buttons-group">
                #if($shiro.hasPermission("goods:save"))
                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                #end
                #if($shiro.hasPermission("goods:update"))
                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                #end
                #if($shiro.hasPermission("goods:delete"))
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
                <i-button type="primary" @click="enSale"><i class="fa fa-hand-o-up"></i>&nbsp;上架</i-button>
                <i-button type="dashed" @click="unSale"><i class="fa fa-hand-o-down"></i>&nbsp;下架</i-button>
            </div>
        </Row>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>
    <Card v-show="!showList">
        <p slot="title">{{title}}</p>
        <Tabs value="name1">
            <Tab-Pane label="通用信息" name="name1">
                <i-form ref="formValidate" :model="goods" :rules="ruleValidate" :label-width="80">
		            <Form-item label="商品类型" prop="goodsType">
		            	<Radio-group v-model="goods.goodsType" @on-change="selectGoodsType">
		                    <Radio v-for="item in goodsTypeList" :label="item.key"><span>{{ item.value }}</span></Radio>
		                </Radio-group>
		            </Form-item>
                    <Row>
                        <i-col span="16">
                            <Form-item label="微信文章URL" prop="wxUrl">
                                <i-input v-model="wxUrl" placeholder="微信文章URL" />
                            </Form-item>
                        </i-col>
                        <i-col span="3">
                            <Form-item :label-width="1">
                                <i-button icon="eye" @click="fetchArticle">获取</i-button>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Form-item label="书名" prop="categoryId">
                        <i-input v-model="goods.categoryName"  readonly="readonly" placeholder="书名"/>
                    </Form-item>
                    <Form-item label="章节名称" prop="name">
                        <i-input v-model="goods.name" placeholder="章节名称"/>
                    </Form-item>
                    <Form-item label="副标题" prop="name">
                        <i-input v-model="goods.goodsSn" placeholder="副标题"/>
                    </Form-item>
                    <Form-item label="本章节数" prop="sortOrder">
                        <Input-number :min="0" :step="1" v-model="goods.sortOrder" placeholder="本章节数"
                                      style="width: 188px;"/>
                    </Form-item>
                    <Form-item label="作者" prop="goodsUnit">
                        <i-input v-model="goods.goodsUnit" placeholder="作者"/>
                    </Form-item>
                    <Row>
                        <i-col span="16">
                            <Form-item label="banner图" prop="primaryPicUrl">
                                <i-input v-model="goods.primaryPicUrl" placeholder="banner图" />
                            </Form-item>
                        </i-col>
                        <i-col span="3">
                            <Form-item :label-width="1">
                                <Upload style="width: 300px;" action="../sys/oss/upload" :format="['jpg','jpeg','png']"
                                        max-size="2048"
                                        :on-success="handleSuccessPicUrl" :on-format-error="handleFormatError"
                                        :show-upload-list="false"
                                        :on-exceeded-size="handleMaxSize">
                                    <i-button icon="ios-cloud-upload-outline">上传图片</i-button>
                                </Upload>
                            </Form-item>
                        </i-col>
                        <i-col span="3">
                            <Form-item :label-width="1">
                                <i-button icon="eye" @click="eyeImagePicUrl">预览图片</i-button>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col span="16">
                            <Form-item label="封面" prop="listPicUrl">
                                <i-input v-model="goods.listPicUrl" placeholder="封面" />
                            </Form-item>
                        </i-col>
                        <i-col span="3">
                            <Form-item :label-width="1">
                                <Upload style="width: 300px;" action="../sys/oss/upload" :format="['jpg','jpeg','png']"
                                        max-size="2048"
                                        :on-success="handleSuccessListPicUrl" :on-format-error="handleFormatError"
                                        :show-upload-list="false"
                                        :on-exceeded-size="handleMaxSize">
                                    <i-button icon="ios-cloud-upload-outline">上传图片</i-button>
                                </Upload>
                            </Form-item>
                        </i-col>
                        <i-col span="3">
                            <Form-item :label-width="1">
                                <i-button icon="eye" @click="eyeImageListPicUrl">预览图片</i-button>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Form-item label="发布" prop="isOnSale">
                        <Radio-group v-model="goods.isOnSale">
                            <Radio label="1">
                                <span>是</span>
                            </Radio>
                            <Radio label="0">
                                <span>否</span>
                            </Radio>
                        </Radio-group>
                    </Form-item>
                    <Form-item label="本章序言" prop="promotionDesc">
                        <i-input v-model="goods.promotionDesc" placeholder="本章序言"/>
                    </Form-item>
                    <Form-item label="本章关键字" prop="keywords">
                        <i-input v-model="goods.keywords" placeholder="多个关键字可空格隔开"/>
                    </Form-item>
                    <div class="upload-list" v-for="item in uploadList">
                        <template v-if="item.status === 'finished'">
                            <img :src="item.imgUrl"/>
                            <div class="upload-list-cover">
                                <Icon type="ios-eye-outline" @click.native="handleView(item.imgUrl)"></Icon>
                                <Icon type="ios-trash-outline" @click.native="handleRemove(item)"></Icon>
                            </div>
                        </template>
                        <template v-else>
                            <Progress v-if="item.showProgress" :percent="item.percentage" hide-info></Progress>
                        </template>
                    </div>
                    <Upload
                            ref="upload"
                            :show-upload-list="false"
                            :default-file-list="uploadList"
                            :on-success="handleSuccess"
                            :format="['jpg','jpeg','png']"
                            :max-size="2048"
                            :on-format-error="handleFormatError"
                            :on-exceeded-size="handleMaxSize"
                            :before-upload="handleBeforeUpload"
                            multiple
                            type="drag"
                            action="../sys/oss/upload"
                            style="display: inline-block;width:58px;">
                        <div style="width: 58px;height:58px;line-height: 58px;">
                            <Icon type="camera" size="20"></Icon>
                        </div>
                    </Upload>
				</i-form>
            </Tab-Pane>
            <Tab-Pane label="详细描述" name="name2">
                <template>
                	 <i-form ref="formValidate" :model="goods" :rules="ruleValidate" :label-width="80">
                     <Row>
                        <i-col span="16">
                            <Form-item label="视频/音频" prop="audioUrl">
                                <i-input v-model="goods.audioUrl" placeholder="视频/音频"/>
                            </Form-item>
                        </i-col>
                        <i-col span="3">
                            <Form-item :label-width="1">
                                <Upload style="width: 300px;" action="../sys/oss/upload" :format="['mp3']"
                                        max-size="20480"
                                        :on-success="handleSuccessAudioUrl" :on-format-error="handleFormatError"
                                        :show-upload-list="false"
                                        :on-exceeded-size="handleMaxSize">
                                    <i-button icon="ios-cloud-upload-outline">上传视频/音频</i-button>
                                </Upload>
                            </Form-item>
                        </i-col>
                     </Row>                
                     <Row>
                        <i-col span="16">
                            <Form-item label="前奏音频" prop="preludeAudioUrl">
                                <i-input v-model="goods.preludeAudioUrl" placeholder="前奏音频"/>
                            </Form-item>
                        </i-col>
                        <i-col span="3">
                            <Form-item :label-width="1">
                                <Upload style="width: 300px;" action="../sys/oss/upload" :format="['mp3']"
                                        max-size="2048"
                                        :on-success="handleSuccessPreludeAudioUrl" :on-format-error="handleFormatError"
                                        :show-upload-list="false"
                                        :on-exceeded-size="handleMaxSize">
                                    <i-button icon="ios-cloud-upload-outline">上传视频/音频</i-button>
                                </Upload>
                            </Form-item>
                        </i-col>
                    </Row>                
                	</i-form>
                    <Modal title="查看图片" v-model="visible">
                        <img :src="imgName" v-if="visible" style="width: 100%"/>
                    </Modal>
                </template>
                <div id="goodsDesc"></div>
            </Tab-Pane>
            <Tab-Pane label="价格体系" name="name3">
                <i-form ref="formValidate" :model="goods" :rules="ruleValidate" :label-width="80">
                	<Row>
	                    <i-button type="success" @click="freeRead">免费</i-button>
	                    <Form-item label="展示价格" prop="counterPrice">
	                    	<Input-number :min="0" :step="1" v-model="goods.counterPrice" placeholder="展示价格"
	                    	style="width: 188px;"/>
	                    </Form-item>
                    </Row>
                    <Form-item label="零售价" prop="unitPrice">
                    <Input-number :min="0" :step="1" v-model="goods.unitPrice" placeholder="零售价"
                    	style="width: 188px;"/>
                    </Form-item>
                    <Form-item label="会员价（7.5折）" prop="retailPrice">
                        <Input-number :min="0" :step="1" v-model="goods.retailPrice" placeholder="会员价（可为0）"
                                      style="width: 188px;"/>
                    </Form-item>
                    <Form-item label="高级会员价（5.8折）" prop="marketPrice">
                        <Input-number :min="0" :step="1" v-model="goods.marketPrice" placeholder="高级会员价（可为0）"
                                      style="width: 188px;"/>
                    </Form-item>
                    <Form-item label="特惠价(4.5折)" prop="appExclusivePrice">
                        <Input-number :min="0" :step="1" v-model="goods.appExclusivePrice" placeholder="特惠价（可为0）"
                                      style="width: 188px;"/>
                    </Form-item>
                </i-form>
            </Tab-Pane>
            <Tab-Pane label="试读信息" name="name4">
                <template>
                	<i-form ref="formValidate" :model="goods" :rules="ruleValidate" :label-width="80">
                    <Row>
                        <i-col span="16">
                            <Form-item label="视频/音频(试读)" prop="testAudioUrl">
                                <i-input v-model="goods.testAudioUrl" placeholder="视频/音频(试读)"/>
                            </Form-item>
                        </i-col>
                        <i-col span="3">
                            <Form-item :label-width="1">
                                <Upload style="width: 300px;" action="../sys/oss/upload" :format="['mp3']"
                                        max-size="4096"
                                        :on-success="handleSuccessTestAudioUrl" :on-format-error="handleFormatError"
                                        :show-upload-list="false"
                                        :on-exceeded-size="handleMaxSize">
                                    <i-button icon="ios-cloud-upload-outline">上传视频/音频</i-button>
                                </Upload>
                            </Form-item>
                        </i-col>
                    </Row>                
                </i-form>
                </template>
                <div id="testContent"></div>
            </Tab-Pane>
        </Tabs>
        <div style="padding-left: 20px; margin-bottom: 30px">
            <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
            <i-button type="warning" @click="reload" style="margin-left: 8px"/>
            返回</i-button>
            <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
        </div>
    </Card>
</div>

<!-- 选择类型 -->
<div id="categoryLayer" style="display: none;padding:10px;">
    <ul id="categoryTree" class="ztree"></ul>
</div>

<script src="${rc.contextPath}/js/novel/article.js?_${date.systemTime}"></script>
</body>
</html>